package com.phz.springcloud.study;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.google.common.collect.Lists;
import com.phz.springcloud.study.vo.cucc.CreditScoreResponse;
@RestController
public class ScoreController {
	
	private static final List<CreditScoreResponse> listScore = Lists.newArrayList(
			new CreditScoreResponse(1,"882.287"),
			new CreditScoreResponse(1,"425.276"),
			new CreditScoreResponse(1,"128.172"),
			new CreditScoreResponse(1,"405.294"),
			new CreditScoreResponse(1,"177.292"),
			new CreditScoreResponse(2,""),
			new CreditScoreResponse(2,""),
			new CreditScoreResponse(2,""),
			new CreditScoreResponse(1302,""),
			new CreditScoreResponse(1302,"")
			);
	
	/**
	 * 模拟联通接口 
	 * 随机返回分数
	 * @return
	 */
	@GetMapping("/score")
	public String register() {
		int num1=(int)(Math.random()*(950-900+1))+900;
		int num2=(int)(Math.random()*(840-830+1))+830;
		String result=String.valueOf(num1)+'.'+String.valueOf(num2);
		return result;
	}
	
	
	@GetMapping("/cucc/score")
	public CreditScoreResponse score() {
		
		return listScore.get((int) (Math.random() * 10));
	}

}
